/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.worsik.vypocty.topeni.tepelneztraty.service;

import java.text.ParseException;

/**
 *
 * @author 231260
 */
public class VypoctyService {
	
	public static double applyDoubleFormat(String text) throws ParseException
	{
		/*
		Number n = format.parse(text);
		double cislo = n.doubleValue();
		
		return cislo;
		*/
		return Double.parseDouble(text.replace(',', '.'));
	}
	
	public static Double tepelnaZtrata(Double plocha, Double soucinitel_prostupu, int teplota_vnitrni, int teplota_za_kci)
	{
		if (plocha == null)
			return 0d;
		if (soucinitel_prostupu == null)
			return 0d;
		return plocha * (soucinitel_prostupu * (teplota_vnitrni - teplota_za_kci));
	}
	
	public static Double infiltrace(Integer delkaSpar, Double soucinitel_i, int char_cislo_budovy, int teplota_vnitrni, int teplota_za_kci)
	{
		Double sum_ilv_x_L = delkaSpar/1000d * soucinitel_i;
		return sum_ilv_x_L * 1300 * 0.0001d * char_cislo_budovy * 0.7d * (teplota_vnitrni - teplota_za_kci);
	}
}
